extends Timer


var time = 0

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	connect("timeout",_on_Timer_timeout)
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
 
	pass

func _on_Timer_timeout():
	# 倒计时结束时的处理逻辑
	
	time = time+1;
	
	if (time>=12):
		time = 0 
		addDay();
	  
	$"../HBoxContainer_food/food".text = str(Global.get("day_num"));
	$"../HBoxContainer_wood/wood".text = str(Global.get("day_num"));
	print("第"+str(Global.get("day_num"))+"天，第"+str(time)+"小时")	
	pass
	
func addDay():
	var dayNum = Global.get("day_num");
	if !dayNum:
		dayNum = 0
	# 获取全局变量 
	dayNum = dayNum+1;
	Global.set("day_num",dayNum)
	
pass
